package org.yuning.cloud.starter.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author zhangzz
 * @email 291110369@qq.com
 * @date 2023/11/10 9:17
 * @description
 **/
public class JsonUtils {

    private static final ObjectMapper objectMapper = new ObjectMapper();
    private static Logger log = LoggerFactory.getLogger(JsonUtils.class);

    public static String object2JsonString(Object object) {
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException e) {
            log.error("转换json字符串出错", e);
        }
        return object.toString();
    }

}
